
/*
 * DiskPanel.java
 *
 * Created on 30/10/2011, 17:23:11
 */

package dud;

/**
 *
 * @author marcio
 */
public class DiskPanel extends javax.swing.JPanel {
    private String diskName;
    private int totalSpaceInMegaBytes;
    
     public DiskPanel() {
        super();
     }

    /** Creates new form DiskPanel */
    public DiskPanel(String diskName, int totalSpaceInMegaBytes) {
        super();
        initComponents();
        this.diskName = diskName;
        this.totalSpaceInMegaBytes = totalSpaceInMegaBytes;
        this.usedSpaceBar.setMaximum(totalSpaceInMegaBytes);
        initInterface();
    } 

    private void initInterface() {
        labelDiskName.setText(diskName);
        labelTotalSpace.setText(totalSpaceInMegaBytes + " MB");
    }

    public void setUsedSpace(int usedSpaceInMegaBytes) {
        usedSpaceBar.setValue(usedSpaceInMegaBytes);
    }

    public String getDiskName() {
        return diskName;
    }


    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        usedSpaceBar = new javax.swing.JProgressBar();
        labelDiskName = new javax.swing.JLabel();
        labelTotalSpace = new javax.swing.JLabel();

        setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true));
        setMaximumSize(new java.awt.Dimension(400, 75));
        setMinimumSize(new java.awt.Dimension(400, 75));
        setPreferredSize(new java.awt.Dimension(400, 75));

        labelDiskName.setText("Unit Name");

        labelTotalSpace.setText("totalSpace");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(labelDiskName, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 185, Short.MAX_VALUE)
                        .addComponent(labelTotalSpace))
                    .addComponent(usedSpaceBar, javax.swing.GroupLayout.DEFAULT_SIZE, 374, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelDiskName)
                    .addComponent(labelTotalSpace))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(usedSpaceBar, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel labelDiskName;
    private javax.swing.JLabel labelTotalSpace;
    private javax.swing.JProgressBar usedSpaceBar;
    // End of variables declaration//GEN-END:variables

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final DiskPanel other = (DiskPanel) obj;
        if ((this.diskName == null) ? (other.diskName != null) : !this.diskName.equals(other.diskName)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 11 * hash + (this.diskName != null ? this.diskName.hashCode() : 0);
        return hash;
    }

    

    

}
